#ifndef __CONNECTDATA__
#define __CONNECTDATA__

#include <iostream>
#include <functional>
#include <string>
#include "Log.hpp"

class webserver;

class ConnectData;

class Thread_Task;

class MyEpoll;
class HttpWork;

class ConnectData
{
    typedef std::function<void(ConnectData*)> fd_func;
public:
    ConnectData(int fd)
        : _fd(fd), _last_time(std::time(nullptr))
    {}

    void SetCallBack(webserver *sever, fd_func read_event, fd_func write_event, fd_func except_event)
    {
        _read_event = read_event;
        _write_event = write_event;
        _except_event = except_event;
        _websever = sever;
    }

    ~ConnectData()
    {
        _websever = nullptr;
    }

    int _fd;
    // 回调函数
    fd_func _read_event;
    fd_func _write_event;
    fd_func _except_event;

    // 超时时间戳
    std::atomic<time_t> _last_time;

    std::string sendbuff;       // 发送缓冲区
    std::string file_address;   // 文件发送缓冲区
    webserver *_websever = nullptr;
};

#endif




